program test_gmres
	use MySparseOperator
    implicit none
    integer :: ia(6), ja(13)
    real(kind=8) :: a(13), expected_solution(5), rhs(5), x(5)
    integer :: mtype, maxiter, iter
    real(kind=8) :: relres
    ia = (/ 1,3,6,9,12,14 /)
    ja = (/ 1,      3,   &
        &   1,  2,      4,  &
        &       2,  3,      5,  &
        &           3,  4,  5,  &
        &               4,  5   /)
    a = (/  1.0,        -1.0,   &
        &   -1.0,   1.0,        -1.0,   &
        &       1.0,    -2.0,       1.0,    &
        &           -1.0,   2.0,    -1.0,   &
        &               -1.0,   -3.0 /)
    expected_solution = (/ -1.0,1.0,0.0,1.0,-1.0 /)
    call mkl_dcsrgemv('n', 5, a, ia, ja, expected_solution, rhs)
    maxiter = 10
    relres = 1.d-3
	call mso_dgmres_precondition(maxiter, relres, a,ia,ja,rhs, x, iter)

    write(*,*) 'A is'
    call mso_prtSpMtxR(a, ia, ja, (/1,5/), (/1,5/), 'f10.1')

    write(unit=*, fmt=*) 'right hand side is'
    write(unit=*, fmt='(5D13.3)') rhs

    write(unit=*, fmt=*) 'expected_solution is'
    write(unit=*, fmt='(5D13.3)') expected_solution

    write(unit=*, fmt=*) 'computed_solution is'
    write(unit=*, fmt='(5D13.3)') x

    write(unit=*, fmt=*) 'the number of iterations is ', iter
    
    
    


end program test_gmres